class Solution {
public:
    int repeatedNTimes(vector<int>& nums) {
        int n = nums.size() / 2;

        // 用map和unordered_map都可以
        // unordered_map<int, int> countMap;
        map<int, int> countMap;
        for(auto e : nums)
            countMap[e]++;

        for(auto kv : countMap)
        {
            if(kv.second == n)
                return kv.first;
        }
        return -1;
    }
};